home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _D68B423EE18743DAB15FD2ED705294C1 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.4 KB  |  44 lines

  1. // ===============================================================
  2. // Vertex Program: 
  3. // Description: 
  4. // Last Update: 14/08/2003
  5. // Coder: Andrey Honich
  6. // ===============================================================
  7.  
  8.       #include "../CGVPMacro.csi"
  9.  
  10.  
  11.       VertAttributes { POSITION_3 TEXCOORD0_2 TANG_3X3 }
  12.       MainInput { VIEWPROJ_MATRIX, LIGHT_POS, CAMERA_POS, ATTEN }
  13.       DeclarationsScript
  14.       {
  15.         IN_T0_TANG
  16.         OUT_T0_T1_T2_T3_C0
  17.       }
  18.       PositionScript = PosCommon
  19.       CoreScript
  20.       {
  21.         OUT.Tex0.xy = IN.TexCoord0.xy;
  22.         OUT.Tex1.xy = IN.TexCoord0.xy;
  23.  
  24.         TANG_MATR
  25.  
  26.         float3 lVec = LightPos.xyz - vPos.xyz;
  27.         float3 lightVec = mul(objToTangentSpace, lVec);          
  28.         float3 vDist = PROC_ATTENPIX;
  29.  
  30.         // transform light vector from object space to tangent space and pass it as a tex coords
  31.         OUT.Tex3.xyz = vDist;
  32.         OUT.Color.xyz = vDist;
  33.         
  34.         // store normalized light vector
  35.         float3 vVec = CameraPos.xyz - vPos.xyz;
  36.         float3 viewVec = mul(objToTangentSpace, vVec);
  37.  
  38.         // compute half angle vector
  39.         float3 halfAngleVector = normalize(viewVec) + normalize(lightVec);
  40.  
  41.         // transform light vector from object space to tangent space and pass it as a tex coords
  42.         OUT.Tex2.xyz = halfAngleVector;
  43.       }
  44.